<%@ page pageEncoding="utf-8" %>
<%@include file="/commons/taglibs.jsp" %>
<!DOCTYPE html>
<html>
<fmt:bundle basename="res">
<head>
    <meta charset="utf-8">
    <title><fmt:message key='fxsgl'/></title>
    <jsp:include page="/WEB-INF/commons/commons-header.jsp" flush="true"/>
</head>
<body>

<div class="layui-fluid">
    <div class="layui-card">
        <form name="totalForm" id="totalForm" class="layui-form layui-card-header layuiadmin-card-header-auto">
            <div class="layui-form-item">

                <div class="layui-inline">
                    <label class="layui-form-label" style="width: 80px;"><fmt:message key='hymc'/></label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" name="username" value="${params.username}">
                    </div>
                </div>

                <div class="layui-inline">
                    <label class="layui-form-label" style="width: 80px;"><fmt:message key='hysjh'/></label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" name="mobile" value="${params.mobile}">
                    </div>
                </div>


                <input type="hidden" value="${userId}" name="userId">
                <input type="hidden" name="type" value="${type}">

                <div class="layui-inline">
                    <button class="layui-btn layui-btn-sm layuiadmin-btn-list" id="search"><i class="layui-icon layui-icon-search layuiadmin-button-btn"></i> <fmt:message key='ss'/></button>
                </div>

            </div>
        </form>
    </div>
</div>

<div class="layui-card">
    <div class="layui-field-box layui-form">

        <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
            <ul class="layui-tab-title">
                <li <c:if test="${type eq 1}">class="layui-this"</c:if> >
                    <a href="${web_domain}/distributor/${userId}/distributorList?type=1&id=${userId}" <c:if test="${type eq 1}">style="color: rgb(0, 150, 136)"</c:if> ><fmt:message key='ckxjfxs'/></a>
                </li>
                <li <c:if test="${type eq 2}">class="layui-this"</c:if>>
                    <a href="${web_domain}/distributor/${userId}/distributorList?type=2&id=${userId}" <c:if test="${type eq 2}">style="color: rgb(0, 150, 136)"</c:if>><fmt:message key='tjxjfxs'/></a>
                </li>
            </ul>
        </div>

        <table class="layui-table" lay-size="sm">
            <thead>
            <tr>
                <th><fmt:message key='xh'/></th>
                <th><fmt:message key='fxsmc'/></th>
                <th><fmt:message key='fxssjh'/></th>
                <th><fmt:message key='fxsdj'/></th>
                <th><fmt:message key='cz'/></th>
            </tr>
            </thead>
            <c:forEach items="${page.result}" var="item" varStatus="status">
                <tr>
                    <td>${status.index + 1}</td>
                    <td>${item.username}</td>
                    <td>${item.mobile}</td>
                    <td>${item.data}</td>
                    <td>
                        <div class="layui-btn-container">

                            <c:if test="${type == 1}">
                                <a href="javascript:void(0);" data-id="${item.id}" class="layui-btn layui-btn-xs feijin-remove" style="background: #009E94"><fmt:message key='sc'/></a>
                            </c:if>

                            <c:if test="${type == 2}">
                                <a href="javascript:void(0);" data-id="${item.id}" data-user="${userId}" class="layui-btn layui-btn-xs feijin-add" style="background: #009E94"><fmt:message key='tj'/></a>
                            </c:if>

                        </div>
                    </td>
                </tr>
            </c:forEach>
        </table>
        <jsp:include page="/commons/page.jsp" flush="true"/>
    </div>
</div>

<script>


    layui.use("layer", function () {

        var layer = layui.layer;

        //删除
        $(".feijin-remove").click(function () {
            var id = $(this).attr("data-id");
            layer.confirm("<fmt:message key='qrscgzhxdxjm?'/>", function () {
                feijin.put({
                    url: "${web_domain}/distributor/removeSubordinate",
                    data: {id: id}
                });
            });
        });

        //添加
        $(".feijin-add").click(function () {
            var id = $(this).attr("data-id");
            var userId = $(this).attr("data-user");
            layer.confirm("<fmt:message key='qrbgzhcwndxjm?'/>", function () {
                feijin.put({
                    url: "${web_domain}/distributor/addSubordinate",
                    data: {id: id, userId : userId}
                });
            });
        });

    });
</script>
</body>
</fmt:bundle>
</html>
